home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / m2doc20 / fmodula2.doc < prev    next >
Text File  |  1988-11-22  |  94KB  |  3,301 lines

  1.  
  2.  
  3.                            Fitted Modula-2 Version 2.0
  4.  
  5.                  (C) Copyright 1987,1988 Fitted Software Tools.
  6.                               All rights reserved.
  7.  
  8.  
  9.                               Fitted Software Tools
  10.                                  P.O.Box 867403
  11.                                  Plano, TX 75086
  12.                                 BBS 214/517-4629
  13.  
  14.  
  15.  
  16.  
  17.      
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.                              DISCLAIMER OF WARRANTY
  29.  
  30.      THIS SOFTWARE AND MANUAL ARE PROVIDED "AS IS" AND WITHOUT WARRANTIES
  31.      AS TO PERFORMANCE OR MERCHANTABILITY.
  32.  
  33.      THIS SOFTWARE IS PROVIDED WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES
  34.      WHATSOEVER. BECAUSE OF THE DIVERSITY OF CONDITIONS AND HARDWARE UNDER
  35.      WHICH THIS SOFTWARE MAY BE USED, NO WARRANTY OF FITNESS FOR A
  36.      PARTICULAR PURPOSE IS OFFERED. THE USER IS ADVISED TO TEST THIS
  37.      SOFTWARE THOROUGHLY BEFORE RELYING ON IT. THE USER MUST ASSUME THE
  38.      ENTIRE RISK OF USING THIS SOFTWARE.
  39.  
  40.      
  41.  
  42.      All the information in this document is believed to be correct at the
  43.      time of publication.  We do, however, reserve the right to make any
  44.      changes in product specifications and/or availability without notice. 
  45.  
  46.      
  47.  
  48.  
  49.  
  50.  
  51.  
  52.      IBM is a registered trademark of International Business Machines
  53.      Corporation.
  54.  
  55.      
  56.  
  57.  
  58.  
  59.  
  60.  
  61.      Introduction                                                         2
  62.      
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                                     Chapter 1
  71.  
  72.                                   Introduction
  73.  
  74.  
  75.  
  76.      Thank you for your interest in our Modula-2 compiler. 
  77.  
  78.      This system features a Modula-2 compiler with an integrated editor and
  79.      "make" facility, a program linker, a makefile generator, and an
  80.      execution profiler. 
  81.  
  82.      The compiler generates code for the Intel 8086 "huge" or "large"
  83.      memory model: In the "huge" memory model, each module has its own data
  84.      and code segment, each of which can be up to 64k in size; In the
  85.      "large" memory model, all the modules' static data is combined into a
  86.      single data segment.  In either model, pointers are 4 bytes long and
  87.      all the leftover memory is available for the "heap". More restrictive
  88.      memory models are not currently supported. 
  89.  
  90.      All the library and runtime support source code is available to our
  91.      registered users (see Shareware).
  92.  
  93.      We hope that our effort will prove itself worthy of your support. 
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.      Introduction                                                         3
  122.      
  123.  
  124.  
  125.  
  126.  
  127.  
  128.      1.1 Hardware requirements
  129.  
  130.  
  131.      This system will run on IBM PC, PC/AT, or compatible systems with at
  132.      least 512K of RAM, two double sided floppy disk drives and a
  133.      monochrome display adapter, color graphics adapter or equivalent. 
  134.  
  135.      A hard disk and 640K of RAM are, however, recommended. 
  136.  
  137.      
  138.  
  139.  
  140.  
  141.  
  142.      1.2 Software requirements
  143.  
  144.  
  145.      This system requires DOS version 2.0 or later. 
  146.  
  147.      No other software is required to use this system, but you will need an
  148.      assembler if you intend to modify one of the runtime support modules:
  149.      M2Reals (floating point support), M2Longs (LONG arithmetic) or M2Procs
  150.      (coroutine handling). 
  151.  
  152.      
  153.  
  154.  
  155.  
  156.  
  157.      1.3 For users upgrading to release 2
  158.  
  159.  
  160.      This is, in a nutshell, what is new in release 2.0.
  161.  
  162.      LONGREALs: You now have a choice of REAL size.  Release 1.x supported
  163.      only the 4 byte real number format, which provided about seven digits
  164.      of accuracy.  The LONGREAL format is 8 bytes and has about 15 digits
  165.      of accuracy.  The tradeoff, of course, is time.  But, if you need
  166.      accurate results in a short time, then... 
  167.  
  168.      8087 support: M2Reals, Mathlib0 and LMathLib0 (MathLib0 for LONGREALs)
  169.      will use the 8087/80287 math coprocessor if one is present.  Inline
  170.      generation of 8087 code is not available at this time.  The inline
  171.      assembler supports all the 8087 mnemonics, but with some
  172.      restrictions. 
  173.  
  174.      OBJ file generation: You may now instruct the compiler to generate DOS
  175.      compatible OBJ files.  Please refer to the chapter on OBJ files for
  176.      more details. 
  177.  
  178.  
  179.  
  180.  
  181.      Introduction                                                         4
  182.      
  183.  
  184.  
  185.      Of special importance the international users, is the fact that the
  186.      editor now accepts characters > 7FX. Indent and unindent commands were
  187.      also added to the editor, as well as 43 or 50 line display support. 
  188.  
  189.      The module RealConversions was added to the system.  You can finaly
  190.      convert floating point numbers to fixed decimal notation! 
  191.  
  192.      This is the most visible stuff.  There are, of course, many more minor
  193.      enhancements in release 2.
  194.  
  195.      Of particular importance (it may affect your code!):
  196.  
  197.           The compiler now generates checks for NIL pointers, when the $T
  198.           directive is in effect.  Also, Storage.DEALLOCATE now sets the
  199.           pointer passed to it to NIL.
  200.  
  201.           In release 1 there were some problems with the implementation of
  202.           type compatibility between CARDINAL and INTEGER: The compiler was
  203.           more strict than the language definition called for.  Some of
  204.           this was fixed along the way in release 1. We hope to have it
  205.           cured now.  When the $R directive is in effect, the compiler
  206.           generates "range check code" on assignments between INTEGERs and
  207.           CARDINALs; basically, if the high order bit is on, the value is
  208.           out of range, regardless of which way you are going.
  209.  
  210.      We owe an apology to many of the users that wrote in (or dialed up)
  211.      with good suggestions.  Although some of these were implemented, many
  212.      were not, not because they were discarded, but because of the
  213.      unnavailability of resources (time, mostly!). 
  214.  
  215.      We hope that you will find this new release a worthy successor to what
  216.      we introduced a little over a year ago. 
  217.  
  218.      
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.      Software installation                                                5
  242.      
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.                                     Chapter 2
  251.  
  252.                               Software installation
  253.  
  254.  
  255.  
  256.      Before starting, please print the file READ.ME, which provides a
  257.      description of every file in the distribution disks. 
  258.  
  259.      
  260.  
  261.  
  262.  
  263.  
  264.      2.1 Theory
  265.  
  266.  
  267.      The library module TermIO (through which Terminal does its I/O)
  268.      requires that the ANSI.SYS driver be installed. 
  269.  
  270.      The executable files (MC.EXE, M2LINK.EXE, ...) should, for ease of
  271.      operation, be placed in a drive/directory named in the DOS PATH
  272.      variable. 
  273.  
  274.      The editor configuration file M2ED.CFG must be accessible through the
  275.      DOS PATH.
  276.  
  277.      Both the compiler and the linker will use the environment variable
  278.      M2LIB to locate required library modules (the format for the M2LIB
  279.      entry matches that of the DOS PATH).
  280.  
  281.      The environment variable M2MODEL may be set to 'HUGE' or 'LARGE',
  282.      after which you no longer have to tell the compiler what memory model
  283.      to compile for (unless you wish to override the environment
  284.      selection).  IF M2MODEL is not set, the compiler, by default (and for
  285.      compatibility with version 1.0), assumes that you want to compile for
  286.      the HUGE model. 
  287.  
  288.      The compiler and utilities in this package do not keep many files open
  289.      simultaneously.  If you set the FILES parameter in CONFIG.SYS to 10
  290.      you should not encounter any problems.  For performance
  291.      considerations, you should also allocate more than the default number
  292.      of buffers for DOS: If you are running on a PC class machine, try
  293.      allocating 20 buffers in your CONFIG.SYS. On an AT class machine, try
  294.      64 buffers. 
  295.  
  296.      Example CONFIG.SYS:
  297.  
  298.  
  299.  
  300.  
  301.      Software installation                                                6
  302.      
  303.  
  304.  
  305.           DEVICE=ANSI.SYS
  306.           FILES=10
  307.           BUFFERS=20
  308.  
  309.      This compiler is a memory hog -- you heard it here first!  This is
  310.      neither good nor bad, simply an implementation decision.  Source
  311.      modules being compiled, for example, are sucked into memory with a
  312.      single read system call. 
  313.  
  314.      Source files (either being compiled or edited) are loaded at the top
  315.      of available memory.  This, of course clobbers the resident portion of
  316.      COMMAND.COM. Because this software was developed on a relatively slow
  317.      system, with a very slow hard disk, we decided that it would be a good
  318.      idea to, on request, preserve the resident portion of COMMAND.COM.
  319.  
  320.      To enable the "COMMAND save" feature of the compiler, which will stop
  321.      it from clobbering the resident portion of COMMAND.COM, just add the
  322.      following line to your AUTOEXEC.BAT file:
  323.  
  324.           SET CMDSIZE=NN
  325.  
  326.      where NN is the size of the resident portion of COMMAND.COM in K (18
  327.      for DOS 3.0).
  328.  
  329.      MC clobbers the top of the memory space available for use during
  330.      initialization.  Therefore, to find out the size of the resident
  331.      portion of COMMAND.COM, try the following procedure: start by setting
  332.      CMDSIZE to the size of COMMAND.COM. If now you execute MC, exit it,
  333.      and press the F3 key, DOS will still remember your MC command. 
  334.      Decrement CMDSIZE and retry the MC test until the system forgets your
  335.      last command (COMMAND.COM had to be reloaded). 
  336.  
  337.      Because the compiler supports 2 different memory models, 2 different
  338.      sets of library object files (.M2O) are provided, one for each of the
  339.      memory models.  If you are going to be using both memory models, keep
  340.      each of these sets of files in a different directory, and change the
  341.      M2LIB path according to the model in use.  We use the following BAT
  342.      files to take care of this:
  343.  
  344.  
  345.      LARGE.BAT:
  346.           set M2MODEL=LARGE
  347.           set M2LIB=C:\M2\LIB;C:\M2\LIBL
  348.  
  349.      HUGE.BAT:
  350.           set M2MODEL=HUGE
  351.           set M2LIB=C:\M2\LIB;C:\M2\LIBH
  352.  
  353.      where \M2\LIB is the directory where all the DEF files reside,
  354.      \M2\LIBL contains the LARGE memory model M2O files,... 
  355.  
  356.      In the following discussion we will, for simplicity sake, assume that
  357.  
  358.  
  359.  
  360.  
  361.      Software installation                                                7
  362.      
  363.  
  364.      you will be using only one of the memory models. 
  365.  
  366.      
  367.  
  368.  
  369.  
  370.  
  371.      2.2 Recommended setup for a system with 2 floppy drives
  372.  
  373.  
  374.      This whole system is too large to fit in a single 360k floppy. 
  375.      Therefore, it is recommended that you build a "compiler" floppy and a
  376.      "utilities" floppy (you may combine them both in a 720k or 1.2Mb
  377.      floppy). 
  378.  
  379.      On the compiler floppy, place the compiler (MC.EXE), all the library
  380.      definition modules (*.DEF), the file M2ED.CFG and DOS' COMMAND.COM.
  381.  
  382.      The utilities floppy will take the rest of the system: the linker
  383.      (M2LINK.EXE), other .EXE files, and the library and runtime support
  384.      object files (*.M2O and *.BIN).
  385.  
  386.      Assuming that you will use drive A for the compiler and utilities disk
  387.      and drive B as your work drive, add the following to your AUTOEXEC.BAT
  388.      file:
  389.  
  390.           SET PATH=A:
  391.           SET M2LIB=A:
  392.  
  393.      If you follow these suggestions, you may use all the system's
  394.      capabilities.  Just remember to swap the floppy in drive A before and
  395.      after invoking the linker from the compiler's menu. 
  396.  
  397.  
  398.  
  399.  
  400.      2.3 Recommended setup for a hard disk system
  401.  
  402.  
  403.      Place the executable files (*.EXE) and M2ED.CFG in a directory
  404.      currently in the DOS search path, or in a new directory (ex: \MODULA2)
  405.      to be added to the PATH list.  Example:
  406.  
  407.           SET PATH=C:\BIN;C:\MODULA2
  408.  
  409.      Make a directory for the library files (ex: \M2LIB) and copy all the
  410.      .DEF, .M2O and .BIN files to it.  To the AUTOEXEC.BAT file add the
  411.      line:
  412.  
  413.           SET M2LIB=C:\M2LIB
  414.  
  415.      You will probably want to create a directory for your own reusable
  416.      library modules.  This directory can be added to the M2LIB environment
  417.  
  418.  
  419.  
  420.  
  421.      Software installation                                                8
  422.      
  423.  
  424.      variable.  Example:
  425.  
  426.           SET M2LIB=C:\M2LIB;C:\MYLIB
  427.  
  428.      You may keep your projects in their own, individual, directories. 
  429.  
  430.      
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.      A little tour through the system                                     9
  482.      
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.                                     Chapter 3
  491.  
  492.                         A little tour through the system
  493.  
  494.  
  495.  
  496.      After you finish the installation as described above, please copy the
  497.      files identified as the "system tour files" in the READ.ME file to
  498.      your work disk or directory. 
  499.  
  500.      Because we do not know your particular system configuration, in the
  501.      following examples we will assume the worst possible scenario. 
  502.      Therefore, some of the capabilities of this system will not be fully
  503.      exploited.  Specifically, we will not invoke the linker or run the
  504.      programs from the compiler menu, neither will we invoke a DOS shell to
  505.      run DBG2MAP.
  506.  
  507.      
  508.  
  509.  
  510.  
  511.  
  512.      3.1 The tour
  513.  
  514.  
  515.      First, we will look at the unnatural case of compiling, linking and
  516.      running a program that works the first time around.  Please execute
  517.      the following commands:
  518.  
  519.           MC SIEVE /C
  520.           M2LINK SIEVE /O
  521.  
  522.      Well, that's it!  Ready to run... 
  523.  
  524.           SIEVE
  525.  
  526.      Now for the more usual case:
  527.  
  528.           MC BADSIEVE
  529.  
  530.      From the compiler menu, select 'C' for compile. 
  531.  
  532.      Gee, that was quick!  Press RETURN to take a look at our errors... 
  533.  
  534.      The cursor is now positioned at the location of the first error. 
  535.      Using the keys Ctrl-E (find next error) and Ctrl-P (find previous
  536.      error) you may visit all the errors flagged by the compiler.  All the
  537.  
  538.  
  539.  
  540.  
  541.      A little tour through the system                                    10
  542.      
  543.  
  544.      while, the editor shows the error description on the top line of the
  545.      screen.  But, going back to the first error... 
  546.  
  547.      We really confused the compiler when we mistakenly typed in '.'
  548.      instead of '..' in the range declaration.  Move the cursor back (left
  549.      arrow key) to where the '.' is, type in another '.', and that should
  550.      fix that!  As you will see as you type Ctrl-E, that single error
  551.      caused the compiler to dislike a few other things on that same line;
  552.      we will just ignore those errors and go on. 
  553.  
  554.      Go on to the next error location (line 22). This time, we should have
  555.      used a ']' but typed '}' instead.  The backspace key will delete the
  556.      offending character; now, type the ']' in its place. 
  557.  
  558.      And that is that.  Shall we try to compile the program again? 
  559.  
  560.      Press Alt-S to save the file, Alt-Q to leave the editor and, back at
  561.      the main menu, select 'C'.
  562.  
  563.      More errors?! 
  564.  
  565.           These errors should have been detected during pass2 of the
  566.           compiler; If not, you may try to fix these errors and recompile,
  567.           or you may opt for loading and compiling the new file
  568.           BADSIEV1.MOD, which contains the earlier fixes.
  569.  
  570.      Going back to the editor... 
  571.  
  572.      We find that we used the identifier 'cnt' which is undefined; we
  573.      really meant to use count.  So, moving the cursor around with the
  574.      cursor keys and/or deleting characters with the backspace or delete
  575.      key, please replace 'cnt' by 'count'.
  576.  
  577.      Searching for the next error... 
  578.  
  579.      The next error occured during the processing of the call to WriteCard.
  580.      What happened here is that WriteCard requires 2 parameters, the second
  581.      one being the size of the field to display.  So, to fix it, let's
  582.      insert a comma after 'count' and some number (for example 'count,4').
  583.  
  584.      Any more erors?  No, that is it... 
  585.  
  586.      We now save the file (Alt-S), quit the editor (Alt-Q) and recompile
  587.      (c).
  588.  
  589.      Now, the program should have compiled without errors.  If not, you may
  590.      recompile BADSIEV2.MOD instead. 
  591.  
  592.      We may now quit the compiler (q).
  593.  
  594.      By now, we have some program that has compiled clean (BADSIEVE,
  595.      BADSIEV1 or BADSIEV2). In what follows, we will assume all went well
  596.      and we have BADSIEVE.
  597.  
  598.  
  599.  
  600.  
  601.      A little tour through the system                                    11
  602.      
  603.  
  604.  
  605.      If you look at the directory, you will see the new object module
  606.      created as a result of the previous exercise (BADSIEVE.M2O). The
  607.      compiler always writes its output to a file with the extension 'M2O'.
  608.  
  609.      Let us link and test the program:
  610.  
  611.           M2LINK BADSIEVE /L
  612.  
  613.      We use the /L option so that the line number information written out
  614.      by the compiler to the object file will be preserved by the linker. 
  615.      We will need this information later. 
  616.  
  617.           BADSIEVE
  618.  
  619.      A runtime error?  And it gives us a PC location.  Very informative, is
  620.      it not?  How in the world are we supposed to fix the program based on
  621.      that?  Do not dispair! 
  622.  
  623.      Looking at your directory, you will notice that the linker created 2
  624.      files: BADSIEVE.EXE and BADSIEVE.DBG.
  625.  
  626.      No, TYPEing BADSIEVE.DBG does not help, it just displays garbage.  But
  627.      we have a utility called DBG2MAP that will convert the information in
  628.      that file to a DOS LINK compatible MAP file.  Let's try it:
  629.  
  630.           DBG2MAP BADSIEVE
  631.  
  632.      Now, using your favorite editor (or the editor in MC: MC BADSIEVE.MAP
  633.      and then E), look at the contents of BADSIEVE.MAP. In the last few
  634.      lines of the file, we have the line number information for BADSIEVE.
  635.      If you look up the line whose address is closest (but lower) to the PC
  636.      in the error message, you get the number of the line where the error
  637.      occured (line 22).
  638.  
  639.      Let's see what happened... 
  640.  
  641.           MC BADSIEVE
  642.  
  643.      Pick 'E' to go into the editor and, either move the cursor down to the
  644.      line indicated by your research, or let the editor find it with Alt-G.
  645.  
  646.      So, what is the problem?  Well, we declared the 'flag' array to have a
  647.      maximum index of 8190, but 'j' got bigger than that (the FOR loop will
  648.      increment 'j' up to the value of 10000).
  649.  
  650.      You may fix the problem by deleting the '10000' and typing in its
  651.      place 'SIZE'.
  652.  
  653.      Recompile the program, link it, and run it.  Did it work?  Good.
  654.  
  655.      It is time for you to experiment on your own.  But, before you do much
  656.      more, you may want to check out the Editor chapter of the
  657.  
  658.  
  659.  
  660.  
  661.      A little tour through the system                                    12
  662.      
  663.  
  664.      documentation. 
  665.  
  666.      
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.      The Compiler                                                        13
  722.      
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                                     Chapter 4
  731.  
  732.                                   The Compiler
  733.  
  734.  
  735.  
  736.      In the Modula-2 language, as defined by Niklaus Wirth, identifiers may
  737.      be used before they are declared, except when they are used in another
  738.      declaration (this restriction does not apply to pointers).  This
  739.      forces the compilation process to be done in at least two passes. 
  740.  
  741.      To avoid imposing unnecessary restrictions and, yet, provide
  742.      reasonable performance, the two pass approach was selected: During the
  743.      first pass, syntax analysis and declaration analysis are performed;
  744.      The second pass performs the semantic analysis and code generation. 
  745.  
  746.      The compiler has an integrated text editor.  Should errors be
  747.      encountered, the editor is invoked at the end of the current compiler
  748.      pass (sooner, if an error is found during the processing of an import
  749.      list or if 20 errors are identified). 
  750.  
  751.      The compiler also has a built in "make" processor.  A makefile must be
  752.      created before this process is invoked.  Although you can create a
  753.      makefile using the editor, we recommend that you use the utility
  754.      provided for that purpose: GENMAKE (this utility may be invoked from
  755.      the compiler menu -- G).
  756.  
  757.      The compiler can generate 2 different kinds of object files as
  758.      output.  By default, M2O (stands for "Modula-2 Object") files are
  759.      generated.  This file format is unique to this compiler, and it is
  760.      optimized for our requirements and those of Modula-2. But the user
  761.      can, through the use of an environment variable (M2OUTPUT), specify
  762.      that standard OBJ files are to be generated instead. 
  763.  
  764.      
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.      The Compiler                                                        14
  782.      
  783.  
  784.  
  785.  
  786.  
  787.  
  788.      4.1 Running the integrated compiler: MC
  789.  
  790.  
  791.      Compiler invocation:
  792.  
  793.           MC [workModule] [/p mainModule] [/s maxIds idSpace] [/c] [/e]
  794.           [/m] [/d-]
  795.  
  796.      The '/p' option may be used to indicate the name of the main module of
  797.      the program that you are working on (the name should not have an
  798.      extension).  If this option is not used, but workModule is entered
  799.      without an extension, the same name is also used for mainModule. 
  800.  
  801.      The '/s' option allows you to change the default sizes of the compiler
  802.      identifier tables.  The two arguments specify the maximum number of
  803.      different identifiers to be processed, and the total string space to
  804.      be allocated to store these identifiers.  The default values are 2000
  805.      and 12000, respectively. 
  806.  
  807.      If you use of the '/c' command line option, the compiler starts
  808.      compiling "workModule" immediately and, if no errors are encountered,
  809.      will bring you right back to the DOS prompt.  This is useful when
  810.      running the compiler from a batch file:
  811.  
  812.           MC myprog /c
  813.  
  814.      The '/e' option will send you straight into the editor. 
  815.  
  816.      The '/m' option invokes the make processor, which will look for the
  817.      file mainModule.MAK for the dependencies list. 
  818.  
  819.      The '/d-' option sets the default value of the compiler directives $R
  820.      and $T to '-', disabling the default generation of most runtime error
  821.      checking.  We do not recommend disabling the stack overflow checking,
  822.      and the use of '/d-' will not do it. 
  823.  
  824.      The compiler always sets the DOS errorlevel to 0 if the last compile
  825.      was successful (no errors); otherwise, the DOS errorlevel is set to 1.
  826.  
  827.      If the compiler is invoked without the '/c', '/e' or '/m' options, you
  828.      will get a screen that looks something like this:
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.      The Compiler                                                        15
  842.      
  843.  
  844.  
  845.  
  846.  
  847.           Modula-2 compiler, Version 2.0
  848.           (C) Copyright 1987,1988 Fitted Software Tools.
  849.           All rights reserved.
  850.  
  851.           Memory model in use: LARGE
  852.           Output file format:  M2O
  853.  
  854.           Heap in use:                   0K
  855.           Available Heap:              249K
  856.  
  857.           Program:     sieve
  858.  
  859.           Work module: sieve.MOD
  860.  
  861.           Program  New   Options  DOS   Quit  dbg2map
  862.           Compile  Edit  Genmake  Make  Link  eXecute >
  863.  
  864.  
  865.  
  866.      The options at this point are:
  867.  
  868.      Program           Specify the name of the main program module. 
  869.  
  870.      New               Specify another "Work module". 
  871.  
  872.      Options           To select the memory model to use. 
  873.  
  874.      DOS               Invoke a new DOS shell.  At the DOS prompt, you
  875.                        should type EXIT to return to this system. 
  876.  
  877.      Quit              Return to DOS.
  878.  
  879.      dbg2map           (2) Execute DBG2MAP, passing as argument the name in
  880.                        Program.
  881.  
  882.      Compile           Compile the "Work module". 
  883.  
  884.      Edit              Edit the "Work module". 
  885.  
  886.      Genmake           Invoke the GenMake program, passing as argument the
  887.                        name in Program -- and '/OBJ', if appropriate. 
  888.  
  889.      Make              Recompile all the necessary modules as per the rules
  890.                        of a makefile (The makefile is assumed to have the
  891.                        name in Program and the extension of .MAK). Note: If
  892.                        errors are encountered during the compilation of one
  893.                        of the modules, the make process is aborted.  After
  894.                        fixing the errors, select Make again. 
  895.  
  896.      Link              Invokes the linker (M2Link) passing along as
  897.  
  898.  
  899.  
  900.  
  901.      The Compiler                                                        16
  902.      
  903.  
  904.                        arguments the name in Program and '/L'.
  905.  
  906.      eXecute           Program is executed. 
  907.  
  908.      
  909.  
  910.  
  911.  
  912.  
  913.      4.2 Running the freestanding compiler: M2COMP
  914.  
  915.  
  916.      Compiler invocation:
  917.  
  918.           M2COMP filename [/m] [/s maxIds idSpace] [/d-]
  919.  
  920.      filename is the name of the module to compile or, if the /M option is
  921.      used, the name of the makefile to process. 
  922.  
  923.      The DOS errorexit is set to 0 if the compilation (make) is successful
  924.      and to 1 otherwise. 
  925.  
  926.      
  927.  
  928.  
  929.  
  930.  
  931.      4.3 The compilation process
  932.  
  933.  
  934.      
  935.  
  936.  
  937.      4.3.0.1 The input file
  938.  
  939.      If the module to be compiled is already loaded into one of the editor
  940.      buffers, that source is compiled.  Otherwise, the compiler tries to
  941.      open the named file. 
  942.  
  943.      
  944.  
  945.  
  946.      4.3.0.2 The imported modules
  947.  
  948.      The compiler and the linker cooperate in assuring that all the modules
  949.      that refer to a particular definition module will have been compiled
  950.      against the same version of that definition module. 
  951.  
  952.      To this end, the compiler places in the 'module header' and 'module
  953.      import' records of the object file a "module key".  This module key is
  954.      the date of the DEF file used during the compilation of the
  955.      implementation module or during the processing of the IMPORT
  956.      statement. 
  957.  
  958.  
  959.  
  960.  
  961.      The Compiler                                                        17
  962.      
  963.  
  964.  
  965.      Due to this, the compiler will not look in the editor buffers for the
  966.      DEF files needed to process an IMPORT list.  These are always read in
  967.      from the disk. 
  968.  
  969.      
  970.  
  971.  
  972.      4.3.0.3 The output file
  973.  
  974.      The output from the compilation of a main module or an implementation
  975.      module is a single output file, with the same name of the source file
  976.      but with the extension of 'M2O' (Modula-2 Object) -- OBJ files are
  977.      created instead, if the environment variable M2OUTPUT so specifies. 
  978.  
  979.      The compilation of a definition module does not generate any new
  980.      output files.  If the compilation is successful (no errors), the
  981.      compiler simply 'touches' the source file, updating its modification
  982.      time. 
  983.  
  984.      
  985.  
  986.  
  987.      4.3.0.4 A warning
  988.  
  989.      Because of the fact that the compiler uses the date of the DEF file as
  990.      that module's key, you may not modify a DEF file unless you intend to
  991.      recompile all the modules that use it, nor can you copy the file in
  992.      such a way that its date is not preserved. 
  993.  
  994.      In particular, if you are going to be transferring your modules
  995.      between computers, you must use some procedure that will preserve all
  996.      the DEF files' dates. 
  997.  
  998.      This is probably a good place to point out that, when you use OBJ
  999.      files, you are not protected by this module version checking. 
  1000.  
  1001.      
  1002.  
  1003.  
  1004.  
  1005.  
  1006.      4.4 Compiler directives
  1007.  
  1008.  
  1009.      Certain compiler code generation options may be set through directives
  1010.      included in the program text.  These directives must appear
  1011.      immediately at the beginning of a comment; multiple directives may be
  1012.      entered in a single comment by separating them by commas.  Example
  1013.  
  1014.           (* $S-, $R+ *)
  1015.  
  1016.      A '+' sets the directive to TRUE, a '-' sets it to FALSE, and a '='
  1017.  
  1018.  
  1019.  
  1020.  
  1021.      The Compiler                                                        18
  1022.      
  1023.  
  1024.      pops the directive's value prior to the last '+' or '-'.
  1025.  
  1026.      The following compiler directives are defined:
  1027.  
  1028.      $A                Alignment. Default $A+. If enabled, all new variables
  1029.                        declared are aligned on a word boundary.  Record
  1030.                        fields are packed (not aligned) regardless of the
  1031.                        setting of this option. 
  1032.  
  1033.      $S                Stack overflow checking.  Default $S+. If enabled,
  1034.                        stack overflow checking is performed on entry to a
  1035.                        procedure and when copying open arrays to a
  1036.                        procedure's local stack frame. 
  1037.  
  1038.      $R                Range checking.  Default $R+. If enabled, before any
  1039.                        assignment is made to a variable of a subrange type,
  1040.                        the value to be assigned is tested against the limits
  1041.                        of the subrange type. 
  1042.  
  1043.      $T                Array subscript and NIL pointer checking.  Default
  1044.                        $T+. If enabled, any time a subscript operation is
  1045.                        performed on an array, the subscript value is checked
  1046.                        to confirm that the operation would not generate an
  1047.                        address outside the bounds of the array.  In
  1048.                        addition, before a pointer is dereferenced, its value
  1049.                        is checked for NIL.
  1050.  
  1051.      $L                Generate line number information.  Default $L-. If
  1052.                        this option is enabled, the compiler will include a
  1053.                        list of source code line numbers and their
  1054.                        corresponding object code offsets in the output
  1055.                        file.  This line number information is passed on to
  1056.                        the .DBG file when the program is linked with the /L
  1057.                        option. 
  1058.  
  1059.      
  1060.  
  1061.  
  1062.      4.4.0.1 Benchmarks
  1063.  
  1064.      If you are going to benchmark the code generated by this compiler,
  1065.      please disable the generation of runtime error checking on all the
  1066.      compilers involved in the comparison. 
  1067.  
  1068.      We feel compelled to spell this out because some other vendors'
  1069.      products do not generate runtime error checking by default. 
  1070.  
  1071.      
  1072.  
  1073.  
  1074.  
  1075.  
  1076.      4.5 Runtime errors
  1077.  
  1078.  
  1079.  
  1080.  
  1081.      The Compiler                                                        19
  1082.      
  1083.  
  1084.  
  1085.  
  1086.      When, during the execution of a program, a runtime error is detected,
  1087.      the runtime error handler will terminate the program and write out a
  1088.      message indicating the type of error encountered and its location (PC
  1089.      address). 
  1090.  
  1091.      To find the location of the error in the source code, run DBG2MAP
  1092.      against the .DBG file generated by M2LINK for this program.  Scanning
  1093.      the .MAP file created, you should be able to always determine the
  1094.      module and procedure where the error occured.  If the $L+ directive
  1095.      was used when compiling the module in question and the /L option was
  1096.      used when linking the program, the error location can be pinpointed to
  1097.      the offending line by scanning the line number information at the end
  1098.      of the .MAP file. 
  1099.  
  1100.      
  1101.  
  1102.  
  1103.      4.5.1 Trapping runtime errors in your program
  1104.  
  1105.      The Library module System provides you with a means of intercepting
  1106.      runtime errors.  The following are the currently defined runtime error
  1107.      numbers that may be passed to your error handler routine:
  1108.  
  1109.           0   stack overflow ($S option)
  1110.           1   range error ($R or $T option)
  1111.           2   integer/cardinal overflow (divide by zero)
  1112.           3   floating point error
  1113.           4   function did not execute a RETURN
  1114.           5   HALT was invoked
  1115.  
  1116.  
  1117.  
  1118.  
  1119.      4.6 Compiler size limits
  1120.  
  1121.  
  1122.      The following are the code and data size limits imposed by this
  1123.      compiler:
  1124.  
  1125.        -  A string constant cannot exceed 80 characters.  This is also the
  1126.           limit set for the size of any identifier. 
  1127.  
  1128.        -  When using the HUGE memory model, each compilation module is
  1129.           assigned its own data segment, which can be up to 64k in size. 
  1130.           In the data segment, the compiler allocates the space for all the
  1131.           module's global variables and some of the module's constants. 
  1132.  
  1133.        -  When using the LARGE memory model, all the modules' data are
  1134.           combined, at link time, into a single data segment (64k
  1135.           maximum). 
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.      The Compiler                                                        20
  1142.      
  1143.  
  1144.        -  The maximum size of a data structure is 65532 bytes. 
  1145.  
  1146.        -  The maximum amount of space allocated for variables local to a
  1147.           procedure is 32000 bytes. 
  1148.  
  1149.        -  The compiler will also refuse to generate the code to pass, in a
  1150.           procedure call, by value, a parameter greater than 65000 bytes in
  1151.           size. 
  1152.  
  1153.      The following are the compiler's internal limits:
  1154.  
  1155.        -  The maximum number of different (namewise) identifiers that can
  1156.           be processed in a single compilation is 2000. May be overwritten
  1157.           at compiler invocation. 
  1158.  
  1159.        -  The total number of characters in all the different (namewise)
  1160.           identifiers processed cannot exceed 12000 characters.  May be
  1161.           overwritten at compiler invocation. 
  1162.  
  1163.        -  No single procedure can be translated into more than 10k of
  1164.           object code. 
  1165.  
  1166.        -  An array of 8k bytes is used to keep track of all the initialized
  1167.           data for a module.  This imposes a limit on the total amount of
  1168.           string, real and long constants used in the compilation module. 
  1169.  
  1170.  
  1171.  
  1172.  
  1173.      4.7 The language supported
  1174.  
  1175.  
  1176.      This release of the compiler will translate a program written in the
  1177.      Modula-2 language as defined by Niklaus Wirth in the 3rd edition of
  1178.      his book "Programming in Modula-2", with the exceptions noted bellow:
  1179.  
  1180.      
  1181.  
  1182.        -  Integer and Cardinal arithmetic overflow is not detected. 
  1183.  
  1184.        -  ASM is a reserved word in this implementation. 
  1185.  
  1186.        -  For those programmers that "grew up" in the Hex world, a way to
  1187.           define CHAR literals in Hex is provided: 20X corresponds to the
  1188.           "space" character in ASCII.
  1189.  
  1190.      
  1191.  
  1192.  
  1193.      4.7.1 LONGINT and LONGCARD
  1194.  
  1195.      This compiler implements the standard types LONGINT and LONGCARD.
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.      The Compiler                                                        21
  1202.      
  1203.  
  1204.      Operands of the type LONGINT or LONGCARD may appear in any expression,
  1205.      just like INTEGER or CARDINAL. But that is about it! 
  1206.  
  1207.      Subranges of these types are not supported. 
  1208.  
  1209.      No standard procedure, except INC, DEC and the ones listed later in
  1210.      this document will accept operands of one of these types. 
  1211.  
  1212.      A variable of type LONGINT or LONGCARD cannot be used as the control
  1213.      variable in a FOR loop.  Neither can CASE labels be of a LONG type. 
  1214.  
  1215.      Constants of type LONGINT or LONGCARD can be coded in decimal only and
  1216.      must be terminated by an 'L' if the value is less than 65536. Example
  1217.  
  1218.           123L and 123567 are valid LONGCARD or LONGINT constant
  1219.  
  1220.           -1L and -348762 are valid LONGINT constants
  1221.  
  1222.  
  1223.      4.7.2 LONGREAL
  1224.  
  1225.      The standard type LONGREAL is implemented. 
  1226.  
  1227.      The rules for the use of LONGREALs are the same as for REALs.
  1228.  
  1229.      The types REAL and LONGREAL are not compatible, and no automatic
  1230.      conversion from one type to another is ever performed -- the standard
  1231.      procedures SHORT and LONG should be used to convert between these
  1232.      types. 
  1233.  
  1234.      Constants of type LONGREAL are no different from REAL constants.  The
  1235.      type of the constant is determined by context.  You may, however,
  1236.      "type" a constant by the use of the SHORT or LONG procedure.  Ex:
  1237.  
  1238.           CONST longreal1 = LONG(1.0);
  1239.  
  1240.  
  1241.      4.7.3 Additional or augmented standard procedures
  1242.  
  1243.  
  1244.      4.7.3.1 NEW and DISPOSE
  1245.  
  1246.      NEW and DISPOSE have been deleted from the language definition in the
  1247.      3rd edition of Wirth's book.  We implement them thus:
  1248.  
  1249.           NEW(p)
  1250.  
  1251.      Invokes the procedure ALLOCATE, which must conform to the type:
  1252.  
  1253.           PROCEDURE ( VAR ADDRESS, CARDINAL )
  1254.  
  1255.      passing along p and the size of the object p is defined as pointing
  1256.      to. 
  1257.  
  1258.  
  1259.  
  1260.  
  1261.      The Compiler                                                        22
  1262.      
  1263.  
  1264.  
  1265.           DISPOSE(p)
  1266.  
  1267.      Invokes the procedure DEALLOCATE, which must conform to the type:
  1268.  
  1269.           PROCEDURE ( VAR ADDRESS, CARDINAL )
  1270.  
  1271.      passing along p and the size of the object p is defined as pointing
  1272.      to. 
  1273.  
  1274.      The procedures ALLOCATE and DISPOSE must, therefore, be defined in the
  1275.      module using NEW and/or DISPOSE, or imported from some other module,
  1276.      like Storage.
  1277.  
  1278.      
  1279.  
  1280.  
  1281.      4.7.3.2 LONG and SHORT
  1282.  
  1283.           PROCEDURE LONG( INTEGER ) :LONGINT;
  1284.  
  1285.           PROCEDURE LONG( CARDINAL ) :LONGCARD;
  1286.  
  1287.           PROCEDURE LONG( REAL ) :LONGREAL;
  1288.  
  1289.           PROCEDURE SHORT( LONGINT ) :INTEGER;
  1290.  
  1291.           PROCEDURE SHORT( LONGCARD ) :CARDINAL;
  1292.  
  1293.           PROCEDURE SHORT( LONGREAL ) :REAL;
  1294.  
  1295.      LONG takes an INTEGER, CARDINAL or REAL and converts it into a LONGINT
  1296.      LONGCARD or LONGREAL, respectively. 
  1297.  
  1298.      SHORT takes a LONGINT, LONGCARD or LONGREAL and converts it into an
  1299.      INTEGER, CARDINAL or REAL, respectively. 
  1300.  
  1301.      
  1302.  
  1303.  
  1304.      4.7.3.3 FLOAT and TRUNC
  1305.  
  1306.      With our two integer/cardinal and real sizes, here is the behavior of
  1307.      the TRUNC and FLOAT procedures. 
  1308.  
  1309.           PROCEDURE FLOAT( CARDINAL ) :REAL;
  1310.  
  1311.           PROCEDURE FLOAT( LONGCARD ) :LONGREAL;
  1312.  
  1313.           PROCEDURE TRUNC( REAL ) :CARDINAL;
  1314.  
  1315.           PROCEDURE TRUNC( LONGREAL ) :LONGCARD;
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.      The Compiler                                                        23
  1322.      
  1323.  
  1324.      
  1325.  
  1326.  
  1327.  
  1328.  
  1329.      4.8 Objects exported by the pseudo module SYSTEM
  1330.  
  1331.  
  1332.      4.8.0.1 TYPE BYTE
  1333.  
  1334.      Takes 1 byte of storage.  Only assignment is defined for this type. 
  1335.      If the formal parameter of a procedure is of type BYTE, the
  1336.      corresponding actual parameter may be of any type that takes 1 byte of
  1337.      storage. 
  1338.  
  1339.      If the formal parameter of a procedure is of type ARRAY OF BYTE, the
  1340.      corresponding actual parameter may be of any type. 
  1341.  
  1342.  
  1343.      4.8.0.2 TYPE WORD
  1344.  
  1345.      Takes 1 word (2 bytes) of storage.  Only assignment is defined for
  1346.      this type.  If the formal parameter of a procedure is of type WORD,
  1347.      the corresponding actual parameter may be of any type that takes 1
  1348.      word of storage. 
  1349.  
  1350.      If the formal parameter of a procedure is of type ARRAY OF WORD, the
  1351.      corresponding actual parameter may be of any type.  Care should be
  1352.      taken in this case, as the size of the parameter passed is rounded up
  1353.      to an even size. 
  1354.  
  1355.  
  1356.      4.8.0.3 TYPE ADDRESS
  1357.  
  1358.      The type ADDRESS is compatible with all pointer types.  ADDRESS itself
  1359.      is defined as a POINTER TO WORD. In this implementation, the type
  1360.      ADDRESS is not compatible with any arithmetic type.  This is due to
  1361.      the fact that the Intel 8086 series processors use segmented
  1362.      addresses.  It would not be hard to implement automatic conversions
  1363.      between LONGCARD and ADDRESS but it is felt that this would be
  1364.      contrary to the spirit of the language, whereby the compiler is not
  1365.      expected to perform any "magic" tricks.  Instead, two functions are
  1366.      provided for that purpose: FLAT and PTR.
  1367.  
  1368.      In release 1.2 we relaxed the above a little.  ADDRESS + CARDINAL and
  1369.      ADDRESS - CARDINAL are legal expressions.  The CARDINAL is added or
  1370.      subtracted from the offset portion of the ADDRESS and the result is
  1371.      still an ADDRESS.
  1372.  
  1373.      Also, INC and DEC can take an ADDRESS as their first argument.  The
  1374.      operation is, however, performed on the offset portion of the ADDRESS
  1375.      only. 
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.      The Compiler                                                        24
  1382.      
  1383.  
  1384.      
  1385.  
  1386.  
  1387.      4.8.0.4 SEG and OFS
  1388.  
  1389.      These are field definitions for POINTER types.  If you import these,
  1390.      you may access the segment or offset portions of a pointer variable
  1391.      using regular field selection syntax.  Example
  1392.  
  1393.           pointer.SEG :segment portion of pointer
  1394.  
  1395.  
  1396.      4.8.0.5 PROCEDURE ADR
  1397.  
  1398.      ADR( designator ) Returns the address of designator (type ADDRESS).
  1399.  
  1400.  
  1401.      4.8.0.6 PROCEDURE FLAT
  1402.  
  1403.      FLAT( ADDRESS ) returns a LONGCARD "flat" address. 
  1404.  
  1405.  
  1406.      4.8.0.7 PROCEDURE PTR
  1407.  
  1408.      PTR( LONGCARD ) returns an ADDRESS corresponding to the "flat" address
  1409.      represented by the LONGCARD.
  1410.  
  1411.  
  1412.      4.8.0.8 PROCEDURE SEGMENT
  1413.  
  1414.      SEGMENT( designator ) returns the segment portion of the address of
  1415.      'designator'. Example:
  1416.  
  1417.           DX := SEGMENT( buffer ); would assign to DX the segment value of
  1418.           ADR(buffer).
  1419.  
  1420.  
  1421.      4.8.0.9 PROCEDURE OFFSET
  1422.  
  1423.      OFFSET( designator ) returns the offset portion of the address of
  1424.      'designator'.
  1425.  
  1426.  
  1427.      4.8.0.10 PROCEDURE NEWPROCESS
  1428.  
  1429.      NEWPROCESS(p:PROC; a:ADDRESS; n:CARDINAL; VAR p1:ADDRESS)
  1430.  
  1431.      creates a new process whose entry point is p and workspace is at a for
  1432.      n bytes.  p1 is the new process pointer.  This process is not
  1433.      activated until a TRANSFER to p1 is done. 
  1434.  
  1435.      The starting priority of the new process is the current processor
  1436.      priority at the time NEWPROCESS is invoked (please refer to the
  1437.  
  1438.  
  1439.  
  1440.  
  1441.      The Compiler                                                        25
  1442.      
  1443.  
  1444.      section on Module Priorities).
  1445.  
  1446.  
  1447.      4.8.0.11 PROCEDURE TRANSFER
  1448.  
  1449.      TRANSFER( VAR p1, p2 :ADDRESS)
  1450.  
  1451.      suspends the current process, assigning it to p1 and resumes p2.  The
  1452.      current process' value is assigned to p1 only after p2 has been
  1453.      identified; it is, therefore, okay for p1 and p2 to be the same. 
  1454.  
  1455.      The process is resumed at the same priority level that it was running
  1456.      at, at the time of suspension. 
  1457.  
  1458.  
  1459.      4.8.0.12 PROCEDURE IOTRANSFER
  1460.  
  1461.      IOTRANSFER( VAR p1, p2 :ADDRESS; intVector :CARDINAL )
  1462.  
  1463.      issues a TRANSFER from p1 to p2 (just the way TRANSFER does it) after
  1464.      installing the current process for reactivation when an interrupt
  1465.      comes in through interrupt vector intVector. 
  1466.  
  1467.      When the interrupt occurs, the interrupt vector is reloaded with its
  1468.      previous value.  A TRANSFER is done to the I/O process (the one that
  1469.      issued the IOTRANSFER) such that p2 now contains the value of the
  1470.      process that was running when the interrupt occured. 
  1471.  
  1472.  
  1473.      4.8.0.13 ASSEMBLER
  1474.  
  1475.      An 8086 inline assembler is provided.  Once ASSEMBLER is imported from
  1476.      SYSTEM, you can enter inline assembler code by bracketing it with the
  1477.      keywords ASM and END.
  1478.  
  1479.      Assembler input is free form.  Comments are entered as in regular
  1480.      Modula-2. Example
  1481.  
  1482.           loop:   CMP  BYTE [SI], 0   (*end of string?*)
  1483.                   MOV  BYTE [DI], [SI]
  1484.                   INC  SI  INC DI     (*increment pointers*)
  1485.                   JMP  loop
  1486.  
  1487.      The assembler accepts all the 8086/8088 opcode mnemonics.  Address
  1488.      operands can be coded in just about any form acceptable to other
  1489.      assemblers, except that the only operator supported if '+'. Operand
  1490.      type overrides are: WORD, BYTE, FAR, NEAR and are not to be followed
  1491.      by the keyword POINTER or PTR. Example
  1492.  
  1493.           label:  MOV  AX, ES:[BX,DI+5]
  1494.                   MOV  AX, ES:5[DI+BX]
  1495.                   MOV  WORD [5], 1
  1496.                   CALL NEAR [DI]
  1497.  
  1498.  
  1499.  
  1500.  
  1501.      The Compiler                                                        26
  1502.      
  1503.  
  1504.                   TEST BYTE i+2, 1
  1505.  
  1506.      All the mnemonics and register names must be entered in upper case. 
  1507.      In case you need to use a Modula-2 name that conflicts with one of the
  1508.      assembler reserved symbols, you may precede it with a '@'. Example
  1509.  
  1510.           MOV @AX, AX
  1511.  
  1512.      would generate a move from register AX to variable AX.
  1513.  
  1514.      All modula-2 variables can generaly be accessed in assembler.  Record
  1515.      field names are not accessible from assembler.  The assembler will not
  1516.      automatically do anything for you.  For example: if you specify a VAR
  1517.      parameter as an operand to an instruction, you are naming the address
  1518.      of the pointer to the actual parameter.  Example
  1519.  
  1520.           PROCEDURE p( VAR done :BOOLEAN );
  1521.           ...
  1522.           ASM
  1523.                LES  DI, done
  1524.                MOV  BYTE ES:[DI], TRUE
  1525.           END;
  1526.  
  1527.      is the correct way of storing TRUE in done. 
  1528.  
  1529.      The following types of constants may be accessed in assembler:
  1530.      INTEGER, CARDINAL, BOOLEAN, CHAR and enumeration constants. 
  1531.  
  1532.      All labels declared inside an ASM section are local to that section of
  1533.      code.  But labels names cannot match some name known in the scope of
  1534.      the current procedure.  Labels can only be referenced in jump
  1535.      instructions. 
  1536.  
  1537.      All jumps are optimized by the compiler.  There is, therefore, no need
  1538.      (or capability) to specify the size of a jump.  In particular, the
  1539.      compiler will turn a conditional jump out of range into a reverse
  1540.      conditional jump over a far jump to the original destination. 
  1541.  
  1542.      Remember, this is a Modula-2 compiler, not an assembler!  The inline
  1543.      assembler capability is provided for use in exceptional situations
  1544.      only. 
  1545.  
  1546.      
  1547.  
  1548.  
  1549.      4.8.0.14 ASSEMBLER - 8087 support
  1550.  
  1551.      All the 8087 math coprocessor instructions are supported by the inline
  1552.      assembler.  There are some restrictions, however. 
  1553.  
  1554.      Only the following operand types are supported by the load and store
  1555.      instructions: INTEGER, LONGINT, REAL and LONGREAL. You may not,
  1556.      therefore, load or store a value in temporary real or decimal format. 
  1557.  
  1558.  
  1559.  
  1560.  
  1561.      The Compiler                                                        27
  1562.      
  1563.  
  1564.  
  1565.      The meaning of the "no operand" form of the arithmetic instructions
  1566.      was retainned:
  1567.  
  1568.           FADD, FSUB, FMUL and FDIV all operate on the two top elements of
  1569.           the 8087 stack, using ST(1) as the destination and removing ST.
  1570.  
  1571.           FSUBR subtracts ST(1) from ST (FDIVR divides ST by ST(1)),
  1572.           leaving the result in ST(1) and removing ST.
  1573.  
  1574.      The 2 operand format of the arithmetic instructions was not
  1575.      implemented.  You may not, therefore, specify a destination register
  1576.      other than ST, except in the "and pop" versions of the instructions. 
  1577.  
  1578.      With a regular assembler, in register to register operations you can
  1579.      specify the register that gets the result of the operation (the
  1580.      destination register).  By definition, the destination register is
  1581.      also the first operand of the instruction. 
  1582.  
  1583.      With our inline assembler, ST is always the destination of the
  1584.      operation, except in the "and pop" form of the instructions, in which
  1585.      case the register specified in the instruction "gets the result". 
  1586.  
  1587.      For consistency, we decided that ST should always be the first operand
  1588.      of the instruction, even when the "and pop" form is used. 
  1589.  
  1590.      The meaning of FSUBP, FSUBRP, FDIVP and FDIVRP is, therefore:
  1591.  
  1592.           FSUBP ST(1) means FSUBRP ST(1),ST -> ST(1):=ST-ST(1)
  1593.  
  1594.           FSUBRP ST(1) means FSUBP ST(1),ST -> ST(1):=ST(1)-ST
  1595.  
  1596.           FDIVP ST(1) means FDIVRP ST(1),ST -> ST(1):=ST/ST(1)
  1597.  
  1598.           FDIVRP ST(1) means FDIVP ST(1),ST -> ST(1):=ST(1)/ST
  1599.  
  1600.      and ST is popped. 
  1601.  
  1602.      
  1603.  
  1604.  
  1605.  
  1606.  
  1607.      4.9 The generated object code
  1608.  
  1609.  
  1610.      
  1611.  
  1612.  
  1613.      4.9.1 Data type representation
  1614.  
  1615.      CHAR              1 byte
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.      The Compiler                                                        28
  1622.      
  1623.  
  1624.      INTEGER           2 bytes 2's complement
  1625.  
  1626.      CARDINAL          2 bytes
  1627.  
  1628.      LONGCARD          4 bytes
  1629.  
  1630.      LONGINT           4 bytes 2's complement
  1631.  
  1632.      BOOLEAN           1 byte (1=TRUE, 0=FALSE)
  1633.  
  1634.      REAL              4 bytes Intel 8087 format. 
  1635.  
  1636.      LONGREAL          8 bytes Intel 8087 format. 
  1637.  
  1638.      BITSET            1 word.  0 is low order bit, 15 is high order bit. 
  1639.  
  1640.      Enumerations      1 byte
  1641.  
  1642.      SETs              1 to 8 words (sets of up to 256 elements)
  1643.  
  1644.      POINTERs          4 bytes in Intel 8086/88 format
  1645.  
  1646.      PROCEDUREs        4 bytes POINTER to procedure entry point
  1647.  
  1648.      Addresses are represented in the default Intel 8086 format:
  1649.  
  1650.           1 word          byte offset
  1651.  
  1652.           1 word          segment
  1653.  
  1654.      Numeric values are likewise represented the way the Intel 8086
  1655.      processor family likes them: low order byte first, high order byte
  1656.      last. 
  1657.  
  1658.      
  1659.  
  1660.  
  1661.      4.9.2 The runtime memory map
  1662.  
  1663.      Currently, the compiler generates code using the "large" or "huge"
  1664.      memory model only. 
  1665.  
  1666.      In the "huge" memory model, each module has its own data and code
  1667.      segments. 
  1668.  
  1669.      In the "large" memory model, each module has its own code segment. 
  1670.      The entire program has one data segment. 
  1671.  
  1672.      The linker binds all the code segments first, and then all the data
  1673.      segments.  The stack is allocated above the data segments.  All the
  1674.      remainning memory is available for the heap. 
  1675.  
  1676.      When a program is loaded for execution, here is what the memory looks
  1677.  
  1678.  
  1679.  
  1680.  
  1681.      The Compiler                                                        29
  1682.      
  1683.  
  1684.      like:
  1685.  
  1686.  
  1687.           From low to high addresses:
  1688.  
  1689.           0         ----------------------------------------------
  1690.                     I  Interrupt vectors                         I
  1691.                     I  DOS                                       I
  1692.           PSP       I  Program segment prefix                    I
  1693.           PSP+100h  I  Program Code segments                     I
  1694.                     I  Program Data segment(s)                   I
  1695.           StackSeg  I  Stack                                     I
  1696.           HeapTop   I  Heap                                      I
  1697.                     I  ...                                       I
  1698.                     I  DOS Command (resident portion)            I
  1699.           MemTop    ----------------------------------------------
  1700.  
  1701.      Label names on the left are the ones exported by System.
  1702.  
  1703.      This system uses interrupt vector 192 (0C0H) at location 0000:0300.
  1704.      Interrupt 192 is issued by a program when a runtime error occurs, when
  1705.      HALT is invoked or when a coroutine other than the main one terminates
  1706.      via a return. 
  1707.  
  1708.      The first word (offset 0) in every code segment contains the data
  1709.      segment value for that particular module (for the program, in the case
  1710.      of the "large" memory model. 
  1711.  
  1712.  
  1713.      4.9.3 Procedure calling conventions
  1714.  
  1715.      Procedure parameters are pushed into the stack 1st argument first. 
  1716.      Control is then transferred to the procedure through a FAR call.  It
  1717.      is the called procedure's responsibility to remove its parameters from
  1718.      the stack before returning. 
  1719.  
  1720.      
  1721.  
  1722.  
  1723.      4.9.3.1 Parameter passing (all except open array parameters)
  1724.  
  1725.      If the formal parameter of a procedure is a value parameter, the
  1726.      actual parameter is copied into the stack. 
  1727.  
  1728.      If the formal parameter is a variable parameter (VAR), the address of
  1729.      the actual parameter is pushed into the stack (first the segment
  1730.      portion of the address and then the offset part). 
  1731.  
  1732.      
  1733.  
  1734.  
  1735.      4.9.3.2 Parameter passing (open array parameters)
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.      The Compiler                                                        30
  1742.      
  1743.  
  1744.      If the formal parameter is an open array, the address and HIGH value
  1745.      of the corresponding formal parameter are pushed into the stack (HIGH
  1746.      value first, and then the address, as above). 
  1747.  
  1748.      If the open array parameter is a value parameter, the value of the
  1749.      actual parameter is copied into the stack on procedure entry. 
  1750.  
  1751.      
  1752.  
  1753.  
  1754.      4.9.3.3 Returning values from a function procedure
  1755.  
  1756.      One byte results are returned in AL, two byte results are returned in
  1757.      AX, and four byte results are returned in DX:AX (DX has the high order
  1758.      part of the result). 
  1759.  
  1760.      LONGREALs are returned in the stack, at a location reserved for that
  1761.      purpose by the caller.  When invoking a function that returns a
  1762.      LONGREAL, an extra parameter is pushed onto the stack: the two byte
  1763.      offset, in the SS segment, of where to place the result.  This choice
  1764.      will make it easy to allow for the return of arbitrary structures from
  1765.      a function, should the language standard go that way, while at the
  1766.      same time allowing for full reentrancy of the code generated. 
  1767.  
  1768.      
  1769.  
  1770.  
  1771.  
  1772.  
  1773.      4.10 Module priorities
  1774.  
  1775.  
  1776.      Eight module priority levels are supported in this implementation,
  1777.      from 0 (highest priority) to 7 (lowest).
  1778.  
  1779.      Priorities are implemented by masking off, on the 8259 interrupt
  1780.      controller, all the interrupts at or below the current priority
  1781.      level. 
  1782.  
  1783.      Because the PC usually runs with several of the interrupt levels
  1784.      disabled, it is not easy to decide what the interrupt mask for the
  1785.      value for "no priority" should be for your particular application. 
  1786.      The implementation of NEWPROCESS, therefore, assumes that you have
  1787.      enabled all the interrupts that your program will be capable of
  1788.      processing before you create your processes.  The value in the
  1789.      interrupt mask register of the 8259 at the time of process creation
  1790.      will determine the initial priority level of this process, once it
  1791.      gets started.  Because of this, invoking NEWPROCESS from inside a
  1792.      priority module is usually not what you want to do! 
  1793.  
  1794.      Execution priorities are changed when entering/exitting procedures in
  1795.      modules that have a priority specification, and during the execution
  1796.      of some form of a TRANSFER.
  1797.  
  1798.  
  1799.  
  1800.  
  1801.      The Compiler                                                        31
  1802.      
  1803.  
  1804.  
  1805.      We highly recommend that you study the communications program
  1806.      provided, paying particular attention to the module Kernel, for an
  1807.      example of how to use priorities with this system. 
  1808.  
  1809.      NOTE: The compiler does not restrict the priority level specified (any
  1810.      number will do).  You must, therefore, exercise care in defining a
  1811.      module's priority level.  On the other hand, it is easy to add
  1812.      additional priority levels by simply modifying the runtime module
  1813.      M2Procs.
  1814.  
  1815.      
  1816.  
  1817.  
  1818.  
  1819.  
  1820.      4.11 Memory models
  1821.  
  1822.  
  1823.      In general, you may compile the same code under either the LARGE or
  1824.      the HUGE memory model. 
  1825.  
  1826.      The only factor to consider is when using inline assembler. 
  1827.  
  1828.      Under the HUGE memory model, the compiler generates code to reload DS
  1829.      after any invocation of an imported procedure or a VARiable
  1830.      procedure.  Under the LARGE memory model, this is not necessary as a
  1831.      single data segment is defined.  If you write some inline assembler
  1832.      code that modifies DS, please restore it, even if the next thing you
  1833.      do is a RETurn; this way, your routine will work regardless of whether
  1834.      you use the LARGE or the HUGE memory model. 
  1835.  
  1836.      Under the HUGE memory model, access to external variables is done
  1837.      through an indirect pointer, whereas in the LARGE memory model the
  1838.      external variable resides in the program's ONLY data segment and is,
  1839.      therefore directly accessible. 
  1840.  
  1841.      
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.      Using OBJ files                                                     32
  1862.      
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.                                     Chapter 5
  1871.  
  1872.                                  Using OBJ files
  1873.  
  1874.  
  1875.  
  1876.      As long as you use this system to write Modula-2 programs for the DOS
  1877.      environment only, there is virtually no reason to use OBJ files.  But,
  1878.      in case you have to... 
  1879.  
  1880.      You condition the compiler to generate OBJ files by setting the
  1881.      environment variable M2OUPUT to OBJ.
  1882.  
  1883.           set M2OUTPUT=OBJ
  1884.  
  1885.      To link OBJ files you must exit the MC environment (or invoke the DOS
  1886.      shell) and use some OBJ file linker. 
  1887.  
  1888.      Also, with OBJ files, there is no module version checking done for
  1889.      you.  Of course, if you keep your ".MAK" files up to date, you should
  1890.      not encounter any problems. 
  1891.  
  1892.      
  1893.  
  1894.  
  1895.  
  1896.  
  1897.      5.1 GenLink
  1898.  
  1899.  
  1900.      To help you figure out which files need to be linked, we provide a
  1901.      utility (GenLink) that generates a LINK answer file.  The LINK answer
  1902.      file created by GenLink lists all the Modula-2 OBJ files that are
  1903.      required to link your program. 
  1904.  
  1905.      Since your program, most likely, requires modules written in another
  1906.      language (or you would not be using OBJ files, right?!), you will have
  1907.      to edit the file created by GenLink to make it suitable. 
  1908.  
  1909.      
  1910.  
  1911.  
  1912.  
  1913.  
  1914.      5.2 Foreign Modules
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.      Using OBJ files                                                     33
  1922.      
  1923.  
  1924.      To let the Modula-2 compiler know about modules written in other
  1925.      languages, you must write FOREIGN DEFINITION modules.  A foreign
  1926.      definition modules is a regular definition module, with the exception
  1927.      of the module's header, which goes like this:
  1928.  
  1929.           FOREIGN [C|PASCAL] DEFINITION MODULE modName;
  1930.  
  1931.      where the 'C' or 'PASCAL' qualifier is optional. 
  1932.  
  1933.      
  1934.  
  1935.  
  1936.      5.2.1 External names
  1937.  
  1938.      Names of public variables and procedures in foreign modules are
  1939.      encoded in one of 3 ways:
  1940.  
  1941.           In a regular FOREIGN (neither C nor PASCAL) module, the
  1942.           identifiers are encoded in the object files as you enter them.
  1943.  
  1944.           In a FOREIGN C module, identifiers are written out preceded by a
  1945.           '_' character.
  1946.  
  1947.           In a FOREIGN PASCAL module, identifiers are converted to all
  1948.           upper case.
  1949.  
  1950.      WARNING: As currently implemented, SET and STRING constants defined in
  1951.      a FOREIGN DEFINITION module, cause the compiler to generate external
  1952.      references to these.  These "constants" should, therefore, be
  1953.      allocated space and properly initialized in the foreign module. 
  1954.  
  1955.      
  1956.  
  1957.  
  1958.      5.2.2 Implementation
  1959.  
  1960.      FOREIGN modules are not expected to have an initialization procedure,
  1961.      and the compiler will not generate these initialization calls, as in
  1962.      the case of regular Modula-2 modules. 
  1963.  
  1964.      
  1965.  
  1966.  
  1967.      5.2.2.1 FOREIGN C modules
  1968.  
  1969.      When invoking a routine defined in a FOREIGN C module, the arguments
  1970.      are pushed onto the stack in reverse order, as per C's custom.  Also,
  1971.      the caller will remove the arguments off the stack upon return from
  1972.      the subroutine. 
  1973.  
  1974.      Since C, unlike Modula-2, supports (?) the passing of a variable
  1975.      number of arguments to a function, the symbol '...' may be used at the
  1976.      end of a PROCEDURE parameter list definition to indicate that an
  1977.  
  1978.  
  1979.  
  1980.  
  1981.      Using OBJ files                                                     34
  1982.      
  1983.  
  1984.      indeterminate number of arguments may be passed.  Example:
  1985.  
  1986.           PROCEDURE sum( n:INTEGER; ... ) :INTEGER;
  1987.  
  1988.      defines a function that takes n integers and returns their sum.  It
  1989.      could, actually, be implemented in Modula-2 thus:
  1990.  
  1991.           PROCEDURE sum( n:INTEGER; ... ) :INTEGER;
  1992.           VAR p   :POINTER TO INTEGER;
  1993.               res :INTEGER;
  1994.           BEGIN
  1995.               res := 0;
  1996.               p := ADR(n) + 2;
  1997.               WHILE n > 0 DO
  1998.                   res := res + p^;
  1999.                   INC( p, 2 );
  2000.                   DEC( n );
  2001.               END;
  2002.               RETURN res;
  2003.           END sum;
  2004.  
  2005.      Good luck! 
  2006.  
  2007.      In addition to being useful to define functions that take a variable
  2008.      number of parameters, the use of '...' is also a handy (?!) way of
  2009.      improving the odds that the arguments are passed in a form that C will
  2010.      like. 
  2011.  
  2012.      
  2013.  
  2014.  
  2015.      5.2.2.2 Parameter passing
  2016.  
  2017.      The form in which the individual parameters are passed is always the
  2018.      same, regardless of whether the procedure is in a foreign module or
  2019.      not.  The exception is when you use '...'.
  2020.  
  2021.      When passing parameters that correspond to the '...' in the procedure
  2022.      heading, the compiler follows the default C rules: Everything is
  2023.      passed by value, except for arrays, which are passed by reference
  2024.      (their address, instead of their value, is pushed onto the stack). 
  2025.  
  2026.      Modula-2 does not allow functions to return structured types.  Some C
  2027.      compilers return structured values by actually returning a pointer to
  2028.      those values in the DX:AX register pair, which is just the way that
  2029.      Fitted Modula-2 returns pointers!  With these, therefore, you could
  2030.      define
  2031.  
  2032.           struct someStruct cfunct()
  2033.  
  2034.      as
  2035.  
  2036.           TYPE someStructPtr = POINTER TO someStruct;
  2037.  
  2038.  
  2039.  
  2040.  
  2041.      Using OBJ files                                                     35
  2042.      
  2043.  
  2044.           PROCEDURE cfunct() :someStructPointer;
  2045.  
  2046.      
  2047.  
  2048.  
  2049.      5.2.3 In the real world...
  2050.  
  2051.      Knowing the parameter passing conventions used by the compiler you
  2052.      should have no trouble writing assembly language modules to be invoked
  2053.      by Modula-2.
  2054.  
  2055.      With the help provided (FOREIGN C and '...'), it should be easy enough
  2056.      to interface Modula-2 to C. But is it, really?  Not quite! 
  2057.  
  2058.      There are two main problems that you will have to overcome.  One, is
  2059.      the choice of a suitable memory model.  Our LARGE memory model is
  2060.      probably a better choice than HUGE, as some compilers require DS to
  2061.      always point to DGROUP.
  2062.  
  2063.      The other problem, is the set of requirements imposed by each
  2064.      language's runtime system.  Since we provide all the source code for
  2065.      our runtime, your best bet will probably be to modify our system to
  2066.      suit theirs.  Modules that are obvious candidates for "adaptation" are
  2067.      System and Storage; In their current state, they are virtually
  2068.      guarateed to not work with another vendor's runtime system, and they
  2069.      are a basis on which many other library modules depend. 
  2070.  
  2071.      
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.      The Text Editor                                                     36
  2102.      
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.                                     Chapter 6
  2111.  
  2112.                                  The Text Editor
  2113.  
  2114.  
  2115.  
  2116.      The text editor included in this package has all the features that you
  2117.      have come to expect from a basic program editor: the ability to
  2118.      insert, delete, move, find and replace text; support for concurrent
  2119.      editing of multiple files (as many as will fit in memory) in separate
  2120.      windows (as many as will fit on the screen) with the ability to copy
  2121.      or move text from window to window. 
  2122.  
  2123.      Although you may load the same file in two different windows, the
  2124.      editor will not be aware of the fact and will treat the two copies as
  2125.      two different files. 
  2126.  
  2127.      The only preset limitation in the editor is that it cannot handle
  2128.      files bigger than 64k. This decision was justified by the fact that
  2129.      Modula-2 programs are supposed to be modular.  File load/save speed
  2130.      was the overriding factor here. 
  2131.  
  2132.      All the text editor keys are defined by the user through the use of
  2133.      the EDCONFIG program.  When the editor starts, it expects to find the
  2134.      file M2ED.CFG in the current PATH.
  2135.  
  2136.      M2ED.CFG will also tell the editor what display colors (attributes) to
  2137.      use for the Status line, for Normal text and for Marked text blocks. 
  2138.  
  2139.      Finally, M2ED.CFG also contains the default settings for the TAB size
  2140.      value, as well as whether or not the editor will expand the tabs
  2141.      inserted into the text spaces.  Note: Tabs present in a file will not
  2142.      be expanded to spaces by the editor. 
  2143.  
  2144.      To get you started, we provide a M2ED.CFG file with the following
  2145.      definitions:
  2146.  
  2147.           Cursor left                    : Left
  2148.           Cursor right                   : Right
  2149.           Cursor up                      : Up
  2150.           Cursor down                    : Down
  2151.           Previous word                  : ^Left
  2152.           Next word                      : ^Righ
  2153.           Page up                        : PgUp
  2154.           Page down                      : PgDn
  2155.           Cursor to beginning of line    : Home
  2156.           Cursor to end of line          : End
  2157.  
  2158.  
  2159.  
  2160.  
  2161.      The Text Editor                                                     37
  2162.      
  2163.  
  2164.           Cursor to top of window        : ^Home
  2165.           Cursor to bottom of window     : ^End
  2166.           To beginning of file           : ^PgUp
  2167.           To end of file                 : ^PgDn
  2168.           Current line to top of window  : AltT
  2169.           Toggle insert/overtype         : Ins
  2170.           Delete character under cursor  : Del
  2171.           Delete previous character      : ^H
  2172.           Delete Current Line            : ^Y
  2173.           Delete to EOL                  : AltY
  2174.           Delete Word                    : ^D
  2175.           Indent Line                    : F4
  2176.           Unindent Line                  : F3
  2177.           Indent Block                   : Alt=
  2178.           Unindent Block                 : Alt-
  2179.           New file                       : AltN
  2180.           Read file                      : AltR
  2181.           Write block                    : AltW
  2182.           Save file                      : AltS
  2183.           Open window                    : ^O
  2184.           Close Window                   : ^C
  2185.           Next window                    : F2
  2186.           Previous window                : aF2
  2187.           Split screen                   : ^S
  2188.           Mark beginning of block        : F7
  2189.           Mark end of block              : F8
  2190.           Goto beginning of block        : AltB
  2191.           Goto end of block              : AltE
  2192.           Clear block marks              : AltH
  2193.           Copy block                     : AltC
  2194.           Delete block                   : AltD
  2195.           Move block                     : AltM
  2196.           Search forward                 : F5
  2197.           Search backwards               : aF5
  2198.           Replace forward                : F6
  2199.           Replace backwards              : aF6
  2200.           Global replace                 : ^F6
  2201.           Repeat last search/replace     : F1
  2202.           Goto next error                : ^E
  2203.           Goto previous error            : ^P
  2204.           Goto line                      : AltG
  2205.           Set options                    : AltO
  2206.           Redraw the screen              : ^L
  2207.           Quit                           : AltQ
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.      The Linker                                                          38
  2222.      
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.                                     Chapter 7
  2231.  
  2232.                                    The Linker
  2233.  
  2234.  
  2235.  
  2236.      The linker is invoked by the command line
  2237.  
  2238.           M2LINK myprog [/s n] [/h n] [/o] [/l] [/swap [path]]
  2239.  
  2240.      where 'myprog' is the main module of the program you are creating. 
  2241.      The options are thus:
  2242.  
  2243.      /s n              n is the size of the stack to allocate (default is
  2244.                        8192).
  2245.  
  2246.      /h n              n is the amount of space to reserve for the heap (in
  2247.                        paragraphs).  The default is all the free memory. 
  2248.  
  2249.      /o                invokes the optimizer.  The optimizer prevents the
  2250.                        output, to the object file, of all the procedures
  2251.                        that are part of included modules but are not
  2252.                        referenced.  This will make your final EXE files
  2253.                        smaller. 
  2254.  
  2255.      /l                tells the linker to process the line number
  2256.                        information in the .M2O files and include it in the
  2257.                        .DBG file.  This option is disabled if the optimizer
  2258.                        is invoked. 
  2259.  
  2260.      /k                tells the linker to ignore module keys, i.e.  to not
  2261.                        check for module version compatibility.  This option
  2262.                        should be used with extreme care. 
  2263.  
  2264.      /swap [path]      tells the linker to use a swap file.  Code segments
  2265.                        will be kept in this swap file instead of in main
  2266.                        memory during the link process.  This allows you to
  2267.                        link larger programs. 
  2268.  
  2269.      The linker creates two files: the .EXE file is your executable
  2270.      program, the .DBG file is a file containning symbol information for
  2271.      use by other utilities (see Map file generator, Profiler).
  2272.  
  2273.      If the /swap directive is used, a swap file is created.  You may
  2274.      select the path (drive:directory) where the swap file is to be
  2275.      created.  Example:
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.      The Linker                                                          39
  2282.      
  2283.  
  2284.           M2LINK myprog /swap D:
  2285.  
  2286.  
  2287.  
  2288.  
  2289.      7.1 Module keys
  2290.  
  2291.  
  2292.      The module header record and the import records written out by the
  2293.      compiler to the object file are stamped with the date of the .DEF file
  2294.      that was processed - this becomes the module key.  The linker will
  2295.      assure that these module keys in the module header of the imported
  2296.      module and in the import record match; If they do not match, both
  2297.      modules were not compiled using the same definition module. 
  2298.  
  2299.      Because of the use of module keys, it is imperative that the date of
  2300.      the distributed .DEF files not be modified unless you intend to
  2301.      recompile the implementation modules. 
  2302.  
  2303.      When using OBJ files, you do not have the protection of Module keys. 
  2304.  
  2305.      
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.      Other utilities                                                     40
  2342.      
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.                                     Chapter 8
  2351.  
  2352.                                  Other utilities
  2353.  
  2354.  
  2355.  
  2356.      
  2357.  
  2358.  
  2359.  
  2360.  
  2361.      8.1 Editor configurator
  2362.  
  2363.  
  2364.      This program lets you define the keystrokes to be used to invoke all
  2365.      the editor commands, the screen attributes (colors) to use, and the
  2366.      default editor options. 
  2367.  
  2368.      Invokation:
  2369.  
  2370.           EDCONFIG
  2371.  
  2372.      EdConfig presents you with a menu from which you may elect to modify
  2373.      the default editor options, the display attributes, or configure the
  2374.      editor commands. 
  2375.  
  2376.      If you are creating a new configuration file, you must configure the
  2377.      editor commands. 
  2378.  
  2379.      If you chose to configure the editor commands, you will be prompted
  2380.      for a log file (default M2ED.HLP), a text file in which all of your
  2381.      command choices will be saved.  You may print this file to create a
  2382.      quick reference card.  EDCONFIG will then prompt you for the key
  2383.      sequence to be used for each editor command.  For each command,
  2384.      EDCONFIG will also give you the option of defining an alternate key
  2385.      sequence. 
  2386.  
  2387.      When you select Quit, the program will prompt you for an output file,
  2388.      the default being 'M2ED.CFG'.
  2389.  
  2390.      
  2391.  
  2392.  
  2393.  
  2394.  
  2395.      8.2 Map file generator
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.      Other utilities                                                     41
  2402.      
  2403.  
  2404.  
  2405.  
  2406.      Invokation:
  2407.  
  2408.           DBG2MAP program_name
  2409.  
  2410.      Reads the .DBG file created by M2LINK and creates a DOS LINK
  2411.      compatible .MAP file. 
  2412.  
  2413.      
  2414.  
  2415.  
  2416.  
  2417.  
  2418.      8.3 Make and the Makefile generator
  2419.  
  2420.  
  2421.      These utilities eliminate the burden, on the user's part, of having to
  2422.      figure out which modules are affected and, therefore, need to be
  2423.      recompiled as a result of any changes to particular definition
  2424.      modules. 
  2425.  
  2426.      GENMAKE creates the .MAK file, the file with all the dependencies
  2427.      (this is the hard part) whereas MAKE (built into the compiler) will
  2428.      insure that these dependencies are observed when updating the object
  2429.      files. 
  2430.  
  2431.      GENMAKE Invokation:
  2432.  
  2433.           GENMAKE main_module_name [/l] [/obj]
  2434.  
  2435.      generates the .MAK file containning all the module dependencies for
  2436.      the named program.  It does this by reading all the IMPORT statements
  2437.      in the main module and, recursively, generating the dependency lists
  2438.      for all those modules.  GENMAKE will indeed read all the .MOD and .DEF
  2439.      files involved. 
  2440.  
  2441.      The /l option instructs GenMake to include the directories listed in
  2442.      the environment variable M2LIB in its search path.  Otherwise, only
  2443.      the modules in the current directory will be taken into consideration
  2444.      when creating the makefile. 
  2445.  
  2446.      The /obj option tells GenMake that you will be using the compiler to
  2447.      generate OBJ files instead of M2O files. 
  2448.  
  2449.      MAKE invocation: see "Running the Compiler".
  2450.  
  2451.      MAKE will invoke the compiler as needed to assure that all the
  2452.      dependencies in the make file are observed.  MAKE is dumb in that it
  2453.      will just run through the makefile sequentially.  It was GENMAKE's
  2454.      responsibility to see that the dependencies are listed in a proper
  2455.      sequence.  Please keep this in mind if you should edit a makefile! 
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.      Other utilities                                                     42
  2462.      
  2463.  
  2464.      
  2465.  
  2466.  
  2467.  
  2468.  
  2469.      8.4 The execution profiler
  2470.  
  2471.  
  2472.      Invokation:
  2473.  
  2474.           M2Prof program_name
  2475.  
  2476.      The profiler will ask you for the name of the .DBG file to use (if it
  2477.      cannot find it) and give you an option of profiling your entire
  2478.      program (generating an execution profile by module), a particular
  2479.      module (generating an execution profile by procedure in that module)
  2480.      or a particular procedure (generating an execution profile by line in
  2481.      the procedure). 
  2482.  
  2483.      Upon program termination, the profiler outputs the list of all the
  2484.      modules/procedures/lines profiled, ranked by execution time, to a file
  2485.      of your choice. 
  2486.  
  2487.      This profiler is not that versatile, but it is useful nevertheless. 
  2488.      It proved instrumental in pinpointing some obvious areas for
  2489.      improvement in the compiler (Oh, we did not tell you, did we?  This
  2490.      compiler was written in the language it compiles -- Modula-2 -- and
  2491.      this system was used as our primary development tool since very early
  2492.      in the development process). 
  2493.  
  2494.      
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.      The Library Modules                                                 43
  2522.      
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.                                     Chapter 9
  2531.  
  2532.                                The Library Modules
  2533.  
  2534.  
  2535.  
  2536.      For complete information on what each library module provides, as well
  2537.      as its proper usage, please refer to the .DEF files. 
  2538.  
  2539.      In addition, the source code of all the library modules is available
  2540.      to all the registered users (see the order form in the back of this
  2541.      document for details). 
  2542.  
  2543.      
  2544.  
  2545.  
  2546.  
  2547.  
  2548.      9.1 Release 2.0 libraries
  2549.  
  2550.  
  2551.      In this release, several library modules were "extended". We have not
  2552.      created any source level incompatibility with previous library
  2553.      modules, that we are aware of.  But you will have to recompile all
  2554.      your programs, as they will not link with the new library modules. 
  2555.  
  2556.      If you customized any of the ASM modules, please note that their
  2557.      format was slightly changed and a module initialization routine is now
  2558.      included. 
  2559.  
  2560.      
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.      The runtime support system                                          44
  2582.      
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.                                    Chapter 10
  2591.  
  2592.                            The runtime support system
  2593.  
  2594.  
  2595.  
  2596.      The library module System contains the runtime system's initialization
  2597.      code.  In particular, special interrupt vectors are loaded with the
  2598.      addresses of routines (also in System) that will handle runtime errors
  2599.      and other abnormal program terminations.  In addition, the module
  2600.      Storage depends on System doing its stuff -- setting the HeapBase,
  2601.      HeapTop and MemTop variables. 
  2602.  
  2603.      Three other special modules are included in this package.  M2Reals,
  2604.      M2Longs and M2Procs. These modules provide support for specific
  2605.      language features. 
  2606.  
  2607.      M2Reals handles all the REAL and LONGREAL arithmetic and conversions. 
  2608.      In release 2, M2Reals checks for the presence of an 8087 math
  2609.      co-processor and uses it, if found. 
  2610.  
  2611.      M2Longs handles LONGINT and LONGCARD arithmetic. 
  2612.  
  2613.      M2Procs provides the coroutine support. 
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.      Shareware                                                           45
  2642.      
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.                                    Chapter 11
  2651.  
  2652.                                     Shareware
  2653.  
  2654.  
  2655.  
  2656.      This software package is distributed as Shareware.
  2657.  
  2658.      If you try this program and continue to use it, you are expected to
  2659.      register with us. 
  2660.  
  2661.      This software can be freely distributed, as long as no money is
  2662.      charged for it, all the files are included, unmodified, and with their
  2663.      modification dates preserved. 
  2664.  
  2665.      This software cannot be distributed as a part of, or in conjunction
  2666.      with, another product. 
  2667.  
  2668.      This software cannot be used in a commercial environment without the
  2669.      payment of a $29 (as of this writing) license fee per copy. 
  2670.  
  2671.      Our success will depend not only on the quality of this software but
  2672.      on the willingness of every individual user to "support" its
  2673.      developers.  If you use this product, please send in the registration
  2674.      form in the back of this document, along with your registration fee. 
  2675.      For a modest $49 (as of this writing), we will send you the latest
  2676.      version of this software and all the library and runtime support
  2677.      source code.  This source code is made available to registered users
  2678.      only. 
  2679.  
  2680.      Whether or not you use this product, please give complete copies of
  2681.      this software to others. 
  2682.  
  2683.      
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.      License terms                                                       46
  2702.      
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                                    Chapter 12
  2711.  
  2712.                                   License terms
  2713.  
  2714.  
  2715.  
  2716.      Before you register this product and become a licensed user, you are
  2717.      granted a limitted license to evaluate the product to determine
  2718.      whether or not it will fit your needs.  Use of this system for any
  2719.      other purpose, before registration and without our written consent, is
  2720.      expressly forbidden. 
  2721.  
  2722.      Registered users are given a non-exclusive license to use this
  2723.      software on any machine that they have access to, but not on more than
  2724.      one at a time (the "treat this software like a book" idea). 
  2725.  
  2726.      Registered users may modify the source code provided to suit their
  2727.      needs, but this source code (in original or modified form) may not be
  2728.      distributed without the prior written consent of Fitted Software
  2729.      Tools.
  2730.  
  2731.      Registered users may include compiled portions of the library and
  2732.      runtime support code in the programs by them developed, and use or
  2733.      distribute these programs without payment of any additional license
  2734.      fees to Fitted Software Tools.
  2735.  
  2736.      
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.      Support                                                             47
  2762.      
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.                                    Chapter 13
  2771.  
  2772.                                      Support
  2773.  
  2774.  
  2775.  
  2776.      Our basic philosophy is very simple: Without happy users, we do not
  2777.      have a business -- or, at least, we will not have one for long! 
  2778.  
  2779.      We will do everything in our power to assure that our users get the
  2780.      kind of support that they deserve and we can afford to provide. 
  2781.  
  2782.      Above all, we do not want to create false expectations on the part of
  2783.      our users, the reason for this chapter. 
  2784.  
  2785.      We currently provide our registered users with support by mail,
  2786.      through BIX (conference 'fst'), or through our BBS, at 214/517-4629.
  2787.  
  2788.      We cannot, of course, promise to fix any bug that you may find within
  2789.      a certain period of time.  As a matter of fact, we do not even promise
  2790.      to fix any and all bugs that you may find, but we will try...  When a
  2791.      fix is not imminent, we will try to give you a workaround procedure,
  2792.      so that you may go on with your work. 
  2793.  
  2794.      As we fix bugs, we will make the new versions of the affected programs
  2795.      available for download from the BBS. Should this not be acceptable to
  2796.      you, you may elect to have the fixes mailed to you, for $5 to cover
  2797.      media and handling charges. 
  2798.  
  2799.      We also make new product updates available for download off the BBS.
  2800.  
  2801.      Registered users have the option of getting software updates by mail
  2802.      instead of downloading them.  The current price of such updates is
  2803.      $12.
  2804.  
  2805.      
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.      Your input matters to us                                            48
  2822.      
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.                                    Chapter 14
  2831.  
  2832.                             Your input matters to us
  2833.  
  2834.  
  2835.  
  2836.      You can bet that this is serious!  We know, and you know, that there
  2837.      are many ways in which this system can be improved.  It is in our
  2838.      common interest that we agree on just how (what needs changing, what
  2839.      additional capabilities are needed) and when (let's take care of the
  2840.      more important stuff first!). 
  2841.  
  2842.      Maybe you like this software so much that you would hate to see us
  2843.      improve it in the wrong direction (ha, ha, ha)... 
  2844.  
  2845.      Maybe you find some weaknesses in this product that make it awkward to
  2846.      use. 
  2847.  
  2848.      Maybe even (God forbid!)  that one or more of those weaknesses make
  2849.      this software unusable for your purposes. 
  2850.  
  2851.      Whichever the case may be, we need to know about it, our future is at
  2852.      stake!!! 
  2853.  
  2854.      So, please!, fill out the survey form and send it in. 
  2855.  
  2856.      
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.                        Your comments would be appreciated
  2884.  
  2885.  
  2886.      How did you first learn about this product?
  2887.  
  2888.           ---------------------------------------------------------
  2889.  
  2890.      Where did you get this software from?
  2891.  
  2892.           ( ) us                   ( ) a bulletin board
  2893.           ( ) a friend                 phone # ___ ___ ____
  2894.           ( ) a computer club      ( ) a shareware software distributor
  2895.           ( ) other ________________________
  2896.  
  2897.      Systems you intend to use this software on
  2898.  
  2899.           ( ) PC (8088/8086)       ( ) AT (80286)      ( ) 80386
  2900.  
  2901.      Typical system's configuration
  2902.  
  2903.           ( ) hard disk
  2904.           ( ) 512k       ( ) 640k
  2905.           ( ) extended memory
  2906.           ( ) expanded memory (EMS, EEMS)
  2907.           ( ) EGA adapter
  2908.           ( ) VGA adapter
  2909.  
  2910.      What programming languages do you use regularly?
  2911.  
  2912.           ---------------------------------------------------------
  2913.  
  2914.      What do you like the most about this system?
  2915.  
  2916.           _____________________________________________________________
  2917.           _____________________________________________________________
  2918.           _____________________________________________________________
  2919.           _____________________________________________________________
  2920.           _____________________________________________________________
  2921.  
  2922.      What do you NOT like about this system?
  2923.  
  2924.           _____________________________________________________________
  2925.           _____________________________________________________________
  2926.           _____________________________________________________________
  2927.           _____________________________________________________________
  2928.           _____________________________________________________________
  2929.  
  2930.      Other comments / suggestions:
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.                                    BUG REPORT
  2944.  
  2945.      We would like to think that our software is bug free, but we have been
  2946.      around a while. 
  2947.  
  2948.      So, if you uncover one of those nasty critters, please provide us with
  2949.      the information below, and whatever else that may help us duplicate
  2950.      the problem. 
  2951.  
  2952.  
  2953.      Name_____________________________________________
  2954.  
  2955.      Company__________________________________________
  2956.  
  2957.      Address__________________________________________
  2958.  
  2959.      City, State, Zip_________________________________
  2960.  
  2961.      Telephone _____________
  2962.  
  2963.  
  2964.      Version of the software in use:  ___________________________
  2965.  
  2966.      Machine in use (make and model): ___________________________
  2967.  
  2968.      Memory / Disks / Display type:   ___________________________
  2969.  
  2970.      Operating system used:           ___________________________
  2971.  
  2972.      Other system information that may be pertinent (PATH settings,
  2973.      CONFIG.SYS contents,...) 
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.      Problem description:
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.                                 REGISTRATION FORM
  3004.  
  3005.      Please mail this form to:
  3006.  
  3007.           Fitted Software Tools
  3008.           P.O.Box 867403
  3009.           Plano, TX 75086
  3010.  
  3011.      to register your copy/copies of the Modula-2 compiler, register/order
  3012.      additional copies, and/or order updates. 
  3013.  
  3014.      The unauthorized distribution of the library and runtime support
  3015.      source code included in the distribution disks that you receive when
  3016.      you order a registered copy or update is specifically prohibited. 
  3017.  
  3018.      If you are ordering multiple copies for your organization (or for you
  3019.      and your friends), we suggest that you order 1 of the $49 packages and
  3020.      the rest as $29 registrations. 
  3021.  
  3022.  
  3023.      Name_____________________________________________
  3024.  
  3025.      Company__________________________________________
  3026.  
  3027.      Address__________________________________________
  3028.  
  3029.      City, State, Zip_________________________________
  3030.  
  3031.  
  3032.      QTY
  3033.      ___   X   Registration & latest version @ $49.00 (*)   _________
  3034.  
  3035.      ___   X   Additional Registrations @ $29.00            _________
  3036.  
  3037.      ___   X   Floppy updates @ $12.00 (**)                 _________
  3038.  
  3039.                Sales tax (TX residents)                     _________
  3040.  
  3041.      Total enclosed:                                        _________
  3042.  
  3043.  
  3044.      Disk format preferred (360k 5-1/4" is the default) ___________
  3045.  
  3046.      If ordering the latest version, please specify how long you are
  3047.      willing to wait for a new, if imminent, update ________________
  3048.  
  3049.      Version of the software (the one displayed in the compiler screen)
  3050.      that you are currently using __________
  3051.  
  3052.      (*) We pay shipping. 
  3053.  
  3054.      (**) For updates outside the USA and Canada, please add an additional
  3055.      $3.00 to help cover the additional shipping cost. 
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.      
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.                            Table of Contents
  3127.  
  3128.  
  3129.      Chapter 1 Introduction                                           2
  3130.  
  3131.         1.1 Hardware requirements                                     3
  3132.         1.2 Software requirements                                     3
  3133.         1.3 For users upgrading to release 2                          3
  3134.  
  3135.      Chapter 2 Software installation                                  5
  3136.  
  3137.         2.1 Theory                                                    5
  3138.         2.2 Recommended setup for a system with 2 floppy drives
  3139.                                                                       7
  3140.         2.3 Recommended setup for a hard disk system                  7
  3141.  
  3142.      Chapter 3 A little tour through the system                       9
  3143.  
  3144.         3.1 The tour                                                  9
  3145.  
  3146.      Chapter 4 The Compiler                                           13
  3147.  
  3148.         4.1 Running the integrated compiler: MC                       14
  3149.         4.2 Running the freestanding compiler: M2COMP                 16
  3150.         4.3 The compilation process                                   16
  3151.  
  3152.               4.3.0.1 The input file                                  16
  3153.               4.3.0.2 The imported modules                            16
  3154.               4.3.0.3 The output file                                 17
  3155.               4.3.0.4 A warning                                       17
  3156.  
  3157.         4.4 Compiler directives                                       17
  3158.  
  3159.               4.4.0.1 Benchmarks                                      18
  3160.  
  3161.         4.5 Runtime errors                                            18
  3162.  
  3163.            4.5.1 Trapping runtime errors in your program              19
  3164.  
  3165.         4.6 Compiler size limits                                      19
  3166.         4.7 The language supported                                    20
  3167.  
  3168.            4.7.1 LONGINT and LONGCARD                                 20
  3169.            4.7.2 LONGREAL                                             21
  3170.            4.7.3 Additional or augmented standard procedures          21
  3171.  
  3172.               4.7.3.1 NEW and DISPOSE                                 21
  3173.               4.7.3.2 LONG and SHORT                                  22
  3174.               4.7.3.3 FLOAT and TRUNC                                 22
  3175.  
  3176.         4.8 Objects exported by the pseudo module SYSTEM              23
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.               4.8.0.1 TYPE BYTE                                       23
  3184.               4.8.0.2 TYPE WORD                                       23
  3185.               4.8.0.3 TYPE ADDRESS                                    23
  3186.               4.8.0.4 SEG and OFS                                     24
  3187.               4.8.0.5 PROCEDURE ADR                                   24
  3188.               4.8.0.6 PROCEDURE FLAT                                  24
  3189.               4.8.0.7 PROCEDURE PTR                                   24
  3190.               4.8.0.8 PROCEDURE SEGMENT                               24
  3191.               4.8.0.9 PROCEDURE OFFSET                                24
  3192.               4.8.0.10 PROCEDURE NEWPROCESS                           24
  3193.               4.8.0.11 PROCEDURE TRANSFER                             25
  3194.               4.8.0.12 PROCEDURE IOTRANSFER                           25
  3195.               4.8.0.13 ASSEMBLER                                      25
  3196.               4.8.0.14 ASSEMBLER - 8087 support                       26
  3197.  
  3198.         4.9 The generated object code                                 27
  3199.  
  3200.            4.9.1 Data type representation                             27
  3201.            4.9.2 The runtime memory map                               28
  3202.            4.9.3 Procedure calling conventions                        29
  3203.  
  3204.               4.9.3.1 Parameter passing (all except open array
  3205.                     parameters)                                       29
  3206.               4.9.3.2 Parameter passing (open array parameters)
  3207.                                                                       29
  3208.               4.9.3.3 Returning values from a function procedure
  3209.                                                                       30
  3210.  
  3211.         4.10 Module priorities                                        30
  3212.         4.11 Memory models                                            31
  3213.  
  3214.      Chapter 5 Using OBJ files                                        32
  3215.  
  3216.         5.1 GenLink                                                   32
  3217.         5.2 Foreign Modules                                           32
  3218.  
  3219.            5.2.1 External names                                       33
  3220.            5.2.2 Implementation                                       33
  3221.  
  3222.               5.2.2.1 FOREIGN C modules                               33
  3223.               5.2.2.2 Parameter passing                               34
  3224.  
  3225.            5.2.3 In the real world...                                 35
  3226.  
  3227.      Chapter 6 The Text Editor                                        36
  3228.  
  3229.      Chapter 7 The Linker                                             38
  3230.  
  3231.         7.1 Module keys                                               39
  3232.  
  3233.      Chapter 8 Other utilities                                        40
  3234.  
  3235.         8.1 Editor configurator                                       40
  3236.         8.2 Map file generator                                        40
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.         8.3 Make and the Makefile generator                           41
  3243.         8.4 The execution profiler                                    42
  3244.  
  3245.      Chapter 9 The Library Modules                                    43
  3246.  
  3247.         9.1 Release 2.0 libraries                                     43
  3248.  
  3249.      Chapter 10 The runtime support system                            44
  3250.  
  3251.      Chapter 11 Shareware                                             45
  3252.  
  3253.      Chapter 12 License terms                                         46
  3254.  
  3255.      Chapter 13 Support                                               47
  3256.  
  3257.      Chapter 14 Your input matters to us                              48
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.